package com.banciyuan.bcywebview.biz.post.write;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.banciyuan.bcywebview.R;

/**
 * Created by hy on 2015/12/30.
 */
public class PostWriteDialog extends Dialog {
    public PostWriteDialog(Context context) {
        super(context);
    }

    public PostWriteDialog(Context context, int theme) {
        super(context, theme);
    }

    protected PostWriteDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public static class Builder {
        private Context context;
        private TextView tvRuleTile, tvRuleContent, tvRuleConfirm;
        private View btnConfirm;
        private ImageView ivConfirm;
        private OnClickListener singleWorkListener;
        private OnClickListener serialWorkListener;

        public Builder(Context context) {
            this.context = context;
        }


        public Builder setTitle(String title) {
            return this;
        }


        public PostWriteDialog create() {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final PostWriteDialog mydialog = new PostWriteDialog(context, R.style.PcHeadDialog);
            View layout = inflater.inflate(R.layout.post_write_dialog, null);
            mydialog.setContentView(layout);
            layout.findViewById(R.id.tv_singelwork).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (null != singleWorkListener)
                        singleWorkListener.onClick(mydialog, DialogInterface.BUTTON_POSITIVE);
                }
            });
            layout.findViewById(R.id.tv_serieswork).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (null != serialWorkListener)
                        serialWorkListener.onClick(mydialog, DialogInterface.BUTTON_NEGATIVE);
                }
            });
            layout.findViewById(R.id.write_parent).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mydialog.dismiss();
                }
            });
            return mydialog;
        }

        public Builder setSingleWorkButton(DialogInterface.OnClickListener listener) {
            this.singleWorkListener = listener;
            return this;
        }

        public Builder setSerialWorkButton(DialogInterface.OnClickListener listener) {
            this.serialWorkListener = listener;
            return this;
        }
    }
}
